//
//  TextureSampling.m
//  Metal-Master
//
//  Created by 杨冰冰 on 2020/6/19.
//  Copyright © 2020 杨冰冰. All rights reserved.
//

#import "TextureSampling.h"
#import "TexturesRenderer.h"

@implementation TextureSampling

{
    MTKView *_view;

    TexturesRenderer *_renderer;
}

- (void)viewDidLoad
{
    // Set the view to use the default device
    _view = [[MTKView alloc] initWithFrame:self.bounds] ;
    
    [self addSubview:_view];
    
    _view.device = MTLCreateSystemDefaultDevice();
    
    NSAssert(_view.device, @"Metal is not supported on this device");
    
    _renderer = [[TexturesRenderer alloc] initWithMetalKitView:_view];
    
    NSAssert(_renderer, @"Renderer failed initialization");

    // Initialize the renderer with the view size
    [_renderer mtkView:_view drawableSizeWillChange:_view.drawableSize];

    _view.delegate = _renderer;
}
@end
